!pr1
Text File Transfer Using DOS 3.3 File Manager.....Bob Potts

Transferring text files from one drive to another can be frustrating and time consuming.  The standard procedure is to read from the file on the source drive and write to the file on the target drive.  One possible solution is to use FID, but you must BRUN FID and cannot use it from inside an Applesoft program.

With this in mind, I set out to write a utility which will transfer a text file using the DOS 3.3 File Manager (FM) routines.  FM has been a part of every release of DOS, but very little documentation has been written about these powerfull routines.  While RWTS concerns itself with tracks and sectors, FM deals with whole files, be they binary, text, or Applesoft.  I recalled that a couple of years ago, Bob Sander-Cederlof had assisted me with a communications program and had used the FM routines to read and store the file.  I located the listing we used, analyzed the code, and here is the result.

The entire program could have been written in assembler, but since most of my programs are in Applesoft (with machine language support routines), I decided to write it as simple as possible.  The name of the file to be transferred, the OPEN, READ, WRITE, and CLOSE commands are all obtained through a short Applesoft front end program.  The machine language portion is broken down as follows.

Lines 1130-1150 are simply easily accessible jump vectors to the two routines which will be CALLed from inside an Applesoft driver.

Lines 1190-1320 clear the buffer, in this case $2000-95FF, to zeroes.  This gives us a buffer of 30,208 bytes, which should be large enough for most text files.  (This is 118 sectors.)  Lines 1330-1340 reset the base buffer address, for use later to find the end of the data in the buffer.

Lines 1360-1460 load the file that has been OPENed by the Applesoft driver.  The process of setting up a FM parameter block is simplified by using a preset data area called RD.BLK, lines 1790-1800.  Calling FM.SETUP sets up the Y- and A-registers properly, and then calling FM.ENTRY reads the text file.

Lines 1500-1580 search through the data buffer for the first occurrence of a 00 byte, which will signal the end of data.  By subtracting the base buffer address in lines 1660-1710 we get the actual length of the data.  Lines 1600-1650 copy in the initial parameter values for writing, and lines 1660-1710 set up the length.

Lines 1720-1740 call on FM to actually write the data on the file that has been opened in the Applesoft driver.

The time saving using this transfer is significant.  A text file containing 8000 bytes took 49 seconds to read and write using pure Applesoft.  Using the FM the same operation was accomplished in only 17 seconds.

Since the program is only 120 bytes long, it can be placed almost anywhere there is free space, especially on page 3.  If you are working from a larger Applesoft program, the starting point for the buffer could be moved as needed to load your text file.

